<?php

namespace app\extra;

class DBCont{

    // 发布状态
    const WAIT_PUBLISH_STATUS = 0;
    const PUBLISH_STATUS = 1;
    const CANCEL_PUBLISH_STATUS = 2;
    static private $_publish_status = array(
        self::WAIT_PUBLISH_STATUS => '未发布',
        self::PUBLISH_STATUS => '已发布',
        self::CANCEL_PUBLISH_STATUS => '已下架',
    );
    // 状态
    const FORBIDDEN_STATUS = 0;
    const NORMAL_STATUS = 1;
    static private $_status = array(
        self::NORMAL_STATUS => '正常',
        self::FORBIDDEN_STATUS => '禁用'
    );
    
    static function __callStatic($name, $arguments)
    {
        $static_name = '_';
        if(preg_match("/get(\w+)List/", $name, $matches)){
            $static_name .= parse_name($matches[1]);
            return self::getFieldList($static_name);
        } elseif (preg_match("/get(\w+)/", $name, $matches)){
            $static_name .= parse_name($matches[1]);
            return self::getFieldValue($static_name, $arguments[0]);
        }
        return null;
    }
    private static function getFieldValue($name, $arg){
        return self::${$name}[$arg];
    }
    private static function getFieldList($name){
        return self::$$name;
    }
    
}

